import logging
import redis


class ConFig(object):
    #开启debug模式
    DEBUG = True
    LOG_LEVEL = logging.DEBUG
    SECRET_KEY='DSkqRiXhVjSB7+Nx0kf3kSN1Kl/lWaTzZJevFbnyyLqM6BfmKq+1BBR6s1rEvIGQ'
    #配置sqlakchemy链接mysql
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/information'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    #让试图函数在修改了数据库的属性的时候，在试图函数结束的时候自动commit一下
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    #配置要链接的redis的端口和地址
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    #配置sessi的储存位置
    SESSION_TYPE='redis'
    SESSION_USE_SIGNER=True  # 设置session的加密
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    SESSION_PERMANENT = False  #默认的session是永久的设置False取消永久的设置
    PERMANENT_SESSION_LIFETIME = 86400 * 2  #设置session的有效时间为两天

class DevelopmentConfig(ConFig):
    DEBUG = True

class ProductionConfig(ConFig):
    DEBUG = False
    LOG_LEVEL = logging.ERROR

class TestConfig(ConFig):
    DEBUG = True
    TESTING = True

config={
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'test': TestConfig
}